
import React, { Component } from 'react';
import zfb from './zfb.png'
import axios from 'axios';
class App extends Component {

  // 创建一个响应式数据
  state = {
    list: []
  }

  // 组件生命周期
  componentDidMount(){
    // axios.get('http://open.douyucdn.cn/api/RoomApi/live').then(res => {
    //   console.log(res);
    // })

    axios.get('/api/RoomApi/live').then(res => {
      console.log(res);
      // 给数据数据设置值
      this.setState({
        list: res.data.data
      })
    })
  }

  render() {
    return (
      <div>
        <img style={{width: '100px'}} src={zfb} alt="" />
        你好中国 {2 + 3}

        <ul>
          {this.state.list.map(item  => {
            return (<li>{item.room_name}</li>)
          })}
        </ul>
      </div>
    );
  }
}

export default App;
